PROJECT_PATH = .

############ 模块信息    #############
MODULE_NAME := Math
MODULE_TARGET := Math.a

# 编译工具
AR = ar
CC = gcc
CXX = g++

# 依赖库, 编译参数
LIBS_DIR += -L./
CFLAGS := -g -w

LIBS += -lpthread

## 编译产物
OUT_PATH := $(PROJECT_PATH)/out
TARGET := $(OUT_PATH)/$(MODULE_TARGET)

ifndef $(wildcard $(OUT_PATH))
$(shell mkdir -p $(OUT_PATH) )
endif

### 头文件路径
INC_DIR := -I$(PROJECT_PATH)/inc

CFLAGS += $(INC_DIR) $(LIBS) $(LIBS_DIR)

#### 源码路径

SRC_CPP := $(PROJECT_PATH)/src
SRC_C := $(PROJECT_PATH)/src
### OBJ 路径
OBJ_DIR := $(OUT_PATH)

### 目标文件
OBJ_CPP := $(patsubst $(SRC_CPP)/%.cpp,$(OBJ_DIR)/%.o, $(wildcard $(SRC_CPP)/*.cpp))
OBJ_C := $(patsubst $(SRC_C)/%.c,$(OBJ_DIR)/%.o, $(wildcard $(SRC_C)/*.c))
$(info $(OBJ_CPP))

################
## 编译目标, 依赖
.PHONY:all
all: $(TARGET)

$(TARGET): $(OBJ_CPP) $(OBJ_C)  $(LIB_STATIC)
	$(AR) rsc $@ $^

## .cpp 目标文件
$(OBJ_DIR)/%.o: $(SRC_CPP)/%.cpp
	$(CXX) -o $@ -c $< $(CFLAGS)

$(OBJ_DIR)/%.o: $(SRC_CPP)/%.c
	$(CXX) -o $@ -c $< $(CFLAGS)

#### 清理
.PHONY:clean
clean:
	-rm $(OUT_PATH)/*.o
	-rm $(TARGET)


